package org.ushio.nchu_22201404.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.ushio.common_module.entity.ComplaintRecord;
import org.ushio.nchu_22201404.service.ComplaintRecordService;

import java.util.List;

@CrossOrigin(origins = "http://localhost:8080")
@RestController
public class ComplaintRecordController {
    @Autowired
    private ComplaintRecordService complaintRecordService;

    @PostMapping("/complaintInsert")
    public String complaintInsert(@RequestBody ComplaintRecord complaintRecord){
        complaintRecordService.complaintInsert(complaintRecord);
        return "投诉记录提交成功，请耐心等待客服回复";
    }

    @PostMapping("/complaintSetIssueResolved")
    public String complaintSetIssueResolved(@RequestBody ComplaintRecord complaintRecord){
        complaintRecordService.complaintSetIssueResolved(complaintRecord);
        return "Complaint Record Update success";
    }

    @RequestMapping("/complaintGetIssueResolved")
    public ComplaintRecord complaintGetIssueResolved(@RequestParam String phoneNumber){
        return complaintRecordService.complaintGetIssueResolved(phoneNumber);
    }

    @PostMapping("/complaintSetIsSigned")
    public String complaintSetIsSigned(@RequestBody ComplaintRecord complaintRecord){
        complaintRecordService.complaintSetIsSigned(complaintRecord);
        return "Complaint Record Update success";
    }

    @RequestMapping("/complaintGetIsSigned")
    public ComplaintRecord complaintGetIsSigned(@RequestParam String phoneNumber){
        return complaintRecordService.complaintGetIsSigned(phoneNumber);
    }

    @RequestMapping("/complaintSelectToCustomerService")
    public List<ComplaintRecord> complaintSelectToCustomerService(){
        return complaintRecordService.complaintSelectToCustomerService();
    }

    @GetMapping("/complaintSelectToAdmin")
    public List<ComplaintRecord> complaintSelectToAdmin(){
        return complaintRecordService.complaintSelectToAdmin();
    }
}
